using System;
using System.Collections.Generic;
using System.Text;

namespace UDS.Management.Data.Exceptions
{
    public class SqlScriptException : DatabaseManagementException
    {
        private const string MESSAGE_FORMATTER = "Error executing script {0}, lines {1} to {2}.  {3}";
        private string scriptName;
        private long startLineNumber;
        private long endLineNumber;

        public SqlScriptException() : base() { }
        public SqlScriptException(string Message) : base(Message) { }
        public SqlScriptException(string ScriptName, long StartingLineNumber, long EndingLineNumber, string SqlMessage)
            : base(String.Format(MESSAGE_FORMATTER, ScriptName, StartingLineNumber.ToString(), EndingLineNumber.ToString(), SqlMessage))
        {
            scriptName = ScriptName;
            startLineNumber = StartingLineNumber;
            endLineNumber = EndingLineNumber;
        }
        public SqlScriptException(string ScriptName, long StartingLineNumber, long EndingLineNumber, string SqlMessage, Exception InnerException)
            : base(String.Format(MESSAGE_FORMATTER, ScriptName, StartingLineNumber.ToString(), EndingLineNumber.ToString(), SqlMessage), InnerException)
        {
            scriptName = ScriptName;
            startLineNumber = StartingLineNumber;
            endLineNumber = EndingLineNumber;
        }
        public SqlScriptException(
            System.Runtime.Serialization.SerializationInfo Info,
            System.Runtime.Serialization.StreamingContext Context)
            : base(Info, Context) { }

        public string ScriptName
        {
            get
            {
                return scriptName;
            }
        }

        public long StartLineNumber
        {
            get
            {
                return startLineNumber;
            }
        }

        public long EndLineNumber
        {
            get
            {
                return endLineNumber;
            }
        }
    }
}
